<?
require_once("cms/core/helper/bean/Abstract.php");
require_once("cms/content/om/ContentLinkPeer.php");
require_once("cms/content/om/ContentI18nPeer.php");

class PHP_CMS_View_Helper_ContentLinks extends AbstractList {

    public function contentLinks($form=null) {

        if($this->isInit)
            return $this;

        parent::init($form);

        $this->criteria->add(ContentLinkPeer::CONTENT_ID, $form->getId());
        $this->criteria->setDistinct();

        if($form->getOrder() == ContentLinkPeer::POSITION) {
            $this->form->setDirection("asc");
        }

        return $this;

    }

    public function getContentI18n() {
        $c = new Criteria();
        $c->add(ContentI18nPeer::CONTENT_ID, $this->form->getId());
        $c->add(ContentI18nPeer::LANGUAGE_CODE, $this->param(_Core::DEFAULT_LANGUAGE));
        return ContentI18nPeer::doSelectOne($c);
    }


    /**
     * Define the propel peer we are going to use to list
     * page items.
     */
    public function getMethod() {
        return "doSelect";
    }


    /**
     * Define the propel peer we are going to use to list
     * page items.
     */
    public static function getPeer() {
        return new ContentLinkPeer();
    }


    /**
     * Return the searchable fields for this list page.
     */
    public static function getFields() {
        return array(
            ContentLinkPeer::NAME,
            ContentLinkPeer::LINK,
            ContentLinkPeer::INSERT_DATE,
            ContentLinkPeer::MODIFIED_DATE
        );
    }
}
?>